#### DEFINE

# Compilateur
CC=gcc

#Option de compilation sur cible
CFLAGS=-c -Wextra -Wall
DFLAGS=-g
CFLAGSCIBLE=-I$(CINCLUDE)
CINCLUDE=/usr/include/tinkerforge

#Librairies
LIBS=-lpthread -lrt -lm
LIBSCIBLE=-ltinkerforge 

#Où se trouve mes sources
SOURCEDIR=.

#Executable, sources et mes sources linké
EXE=nannyBear
SOURCES= *.c
COMPILEDSOURCES=$(SOURCES:.c=.o)

#Eviter les fautes de frappe
Debug=DEBUG
debug=DEBUG
OnPC=onPC
onpc=onPC
ONPC=onPC

#### BUILD RULES

all: clean $(EXE)

DEBUG: clean CFilesDebug
	$(CC) $(COMPILEDSOURCES) -o $(EXE) $(LIBS)
	rm $(COMPILEDSOURCES)

onPC: clean CFilesPC
	$(CC) $(COMPILEDSOURCES) -o $(EXE) $(LIBS)
	rm $(COMPILEDSOURCES)


$(EXE): CFiles
	$(CC) $(COMPILEDSOURCES) -o $(EXE) $(LIBS) $(LIBSCIBLE)
	rm $(COMPILEDSOURCES)

CFilesDebug: 
	$(CC) $(CFLAGS) $(DFLAGS) $(SOURCEDIR)/model/$(SOURCES) $(SOURCEDIR)/com/$(SOURCES) $(SOURCEDIR)/$(SOURCES)

CFilesPC: 
	$(CC) $(CFLAGS) $(SOURCEDIR)/model/$(SOURCES) $(SOURCEDIR)/com/$(SOURCES) $(SOURCEDIR)/$(SOURCES)

CFiles: 
	$(CC) $(CFLAGS) $(CFLAGSCIBLE) $(SOURCEDIR)/model/$(SOURCES) $(SOURCEDIR)/com/$(SOURCES) $(SOURCEDIR)/$(SOURCES)

clean:
	rm -f *.o $(EXE)
